package com.pagoda.nerp.web.configuration;

import com.pagoda.nerp.web.services.EHRService;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;

@Configuration
public class WebServiceEHR {

    @Value("${client.url}")
    private String clienturl;
    @Value("${webservices.packagepath}")
    private String packagepath;

    @Bean
    public Jaxb2Marshaller marshaller(){
        Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

        marshaller.setContextPath(packagepath);

        return marshaller;
    }

    @Bean
    public EHRService ehrService(Jaxb2Marshaller marshaller){
        EHRService client = new EHRService();
        client.setDefaultUri(clienturl);
        client.setMarshaller(marshaller);
        client.setUnmarshaller(marshaller);
        return client;
    }
}
